package com.xindacloud.sms.adapter.config;


import com.xindacloud.sms.adapter.service.notify.NotifyExecutor;
import com.xindacloud.sms.adapter.constant.QueueConstant;
import com.xindacloud.sms.adapter.exchange.ExchangeMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.aws.messaging.listener.SqsMessageDeletionPolicy;
import org.springframework.cloud.aws.messaging.listener.annotation.SqsListener;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;


@Slf4j
@Configuration
@Component
public class SQSMessageListenerConfig {


    private final NotifyExecutor notifyExecutor;

    @Autowired
    public SQSMessageListenerConfig(NotifyExecutor notifyExecutor) {
        this.notifyExecutor = notifyExecutor;
    }

    @SqsListener(value = {QueueConstant.HXD_SUBMIT_SMS_AWS_SQS_REQUEST_KEY}, deletionPolicy = SqsMessageDeletionPolicy.NO_REDRIVE)
    private void onReceiverNotifyMessage(ExchangeMessage payload) {
        notifyExecutor.handleNotifyMessage(payload);
    }
}
